/*
 *--------------------------------------------------------------------------
 *   Battlefield - A Realtime Network Multiplayer Game
 *   =======================================================
 *   Developed by Group D02 - 2009/2010 Semester 4 - CS2103
 *     Harry Nguyen Duy Hoang <nnduyhoang@yahoo.co.uk>
 *     Kent Chng Siang Rong <fivefootway@gmail.com>
 *     Lim Yong Peng <limpeng1986@gmail.com>
 *     Loh Xiankun <u0807185@nus.edu.sg>
 *   Instructed by
 *     Dr. Damith C.Rajapakse <damith@gmail.com>
 *   =======================================================
 *   $Id: InventoryButton.java 563 2010-07-25 20:54:40Z Harry $
 *   $LastChangedDate: 2010-07-25 20:54:40 +0000 (Sun, 25 Jul 2010) $
 *   $LastChangedBy: Harry $
 *--------------------------------------------------------------------------
 */
package battlefield.ui.component;

import battlefield.resource.Graphics;
import battlefield.entity.Cell;
import battlefield.entity.UnitModel;
import javax.swing.ImageIcon;

/**
 *
 * @author Harry Nguyen
 */
public class InventoryButton extends GameToggleButton {

    public final static int WIDTH = 90;
    public final static int HEIGHT = 90;
    private UnitModel unitModel;

    public InventoryButton(UnitModel unitModel) {
        this.unitModel = unitModel;
        initComponents();
    }

    private void initComponents() {
        this.setIcon(new ImageIcon(Graphics.get(unitModel.getUnitImage(), Cell.WIDTH, Cell.HEIGHT).getImage()));
        this.setText("<html><center>" + unitModel.getName() + "<BR />" + (unitModel.getPrice() > 0 ? "<font color='red'>" + unitModel.getPrice() + "</font>" : "") + "</center></html>");
        this.setNormalImage(Graphics.BUTTON_TOGGLE_NORMAL.resize(WIDTH, HEIGHT).getImage());
        this.setHoverImage(Graphics.BUTTON_TOGGLE_HOVER.resize(WIDTH, HEIGHT).getImage());
    }

    public UnitModel getUnitModel() {
        return unitModel;
    }

    public void setUnitModel(UnitModel unitModel) {
        this.unitModel = unitModel;
    }
}
